<?php

namespace App\Service\Friend;

// use App\Constants\ErrorCode;
use App\Model\UserProfile;
use App\Service\BaseService;

/**
 * 首页展示头像(特效头像列表)
 */
class ShowListService extends BaseService
{
    public function handle()
    {
        $userId = $this->getUserId();
        // $userProfile = UserProfile::getProfile($userId);
        $ret['list'] = [];
        //获取一批用户头像
        $showUserIds = UserProfile::getNewUsers(UserProfile::ROLE_USER, 1);
        $showUserIds = array_slice($showUserIds, 0, $this->pageNum);
        $usersInfo = UserProfile::getUsersProfile($showUserIds);
        array_walk($usersInfo, function ($userProfile) use (&$ret) {
            $ret['list'][] = [
                'user_id' => $userProfile['user_id'],
                'avatar' => UserProfile::buildAvatar($userProfile['avatar'], 50),
            ];
        });
        return $ret;
    }
}
